home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Mac Game Programming Gurus
/
TricksOfTheMacGameProgrammingGurus.iso
/
More Source
/
Libraries
/
SAT 2.3b4
/
Demo ƒ
/
Collision][ demo ƒ
/
Collision][.p
< prev
next >
Wrap
Text File
|
1995-01-27
|
2KB
|
64 lines
{******************************}
{********* SAT Collision ][ **********}
{******************************}
{A more advanced version of SAT Collision, demonstrating the use of callback routines}
{(hit task) for collision handling. What has happened is that the apples switch between}
{good and bad, and we are not supposed to eat it when it's bad.}
program SATcollisionII;
uses
{$ifc UNDEFINED THINK_PASCAL}
Types, QuickDraw, Menus, Windows, TextEdit, Fonts, Dialogs, Memory, {OSEvents,{}
{$endc}
SAT, sMrEgghead, sApple;
var
ignoreSp: SpritePtr;
l: longint;
ignore: integer;
p: Point;
begin
{Standard Inits are done by Think Pascal.}
{$ifc UNDEFINED THINK_PASCAL}
InitGraf(@qd.thePort);
InitFonts;
InitWindows;
{InitMenus;}
{TEInit;}
InitDialogs(nil);
MaxApplZone;
{$endc}
{We configure for kBackwardCollision. We can't use kKindCollision here, since we want "friends"}
{to hit each other as well as "enemies".}
SATConfigure(true, kVPositionSort, kBackwardCollision, 32);
SATInit(128, 129, 512, 322);
InitMrEgghead;
InitApple;
GetMouse(p);
ignoreSp := SATNewSprite(0, p.h, p.v, @SetupMrEgghead);
ignoreSp := SATNewSprite(0, 0, SATRand(gSAT.offSizeV - 32), @SetupApple);
HideCursor;
{Optional init for better sound. Get two channels if possible, since we use fairy long sounds.}
ignore := SATSoundInitChannels(2);
repeat
l := TickCount;
SATRun(true);
{Start a new sprite once in a while.}
if SATRand(40) = 1 then
ignoreSp := SATNewSprite(0, 0, SATRand(gSAT.offSizeV - 32), @SetupApple);
while l > TickCount - 2 do {Maximize speed to 30 fps}
;
until Button;
ShowCursor;
FlushEvents(mDownMask, 0); {Flush the mouse click, so we won't click randomly in the Finder!}
SATSoundShutUp; {Always make sure the sound channel is de-allocated!}
end.